#include"processbar.h"
#include<unistd.h>
#include<string.h>
const char* lable = "|/-\\";
char buffer[MAX] = {0};
void process_flush(double rate)
{
    static int count = 0;
    int n = strlen(lable);
    if(rate<=1.0) buffer[0] = head;
    printf("\033[0m");//清空设置
    printf("\033[1;31m");//填写设置
    printf("[%-100s][%.1f%%][%c]\r",buffer,rate,lable[count%n]);
    printf("\033[0m");//清空设置
    fflush(stdout);
    buffer[(int)rate] = body;
    if((int)rate<100)buffer[(int)rate+1] = head;
    count++;
    count%=n;
}
//const char* LABLE="|/-\\";
//char buffer[MAX] = {0};
//void process_flush(double rate)
//{
//    int count = (int)rate;
//    int n = strlen(LABLE);
//    if(rate<=1.0) buffer[0] = head;
//    printf("[%-100s][%.1f%%][%c]\r",buffer,rate,LABLE[count%n]);
//    fflush(stdout);
//    buffer[count++] = body;
//    if(count<100)buffer[count] = head;
//}
